/*-------------------------------------------------------------------------*/
/**
  @file		proto.h
  @author	Renaud Wanchoor
  @date	July 2004
  @version	$Revision: 2.5 $
  @brief	function declarations
  @update date	March 2007 by Xiaochen Wu
  
*/
/*--------------------------------------------------------------------------*/
#ifndef PROTO_H
#define PROTO_H

/* coarsen.h */
GraphType* Coarsen(GraphType *, GridType *, PartInfoType *);

/* contract.h */
GraphType* Contract(GraphType *graph, int *guide, int numVtxs);

/* match.h */
GraphType* LAM(CoaCtrl* coactrl);
GraphType* MWM(CoaCtrl* coactrl);
GraphType* MHem(CoaCtrl* coactrl);
GraphType* Hem(CoaCtrl* coactrl);
GraphType* Rm(CoaCtrl* coactrl);

/* graph_func.h */
GraphType* LIBG_Init(void);
void       LIBG_Allocate(GraphType* g);
GraphType* LIBG_Read(FILE *fp);
void       LIBG_Free(GraphType* graph);

/* grid_func.h */
void       IniProcessorCon(GridType* grid,GraphType* graph);
void       UpdateProcessorCon(GridType* grid,GraphType* graph,
			int vtx,int from, int to);
void       debugProcessorCon(GridType* grid,GraphType* graph);
void       SwapProcessors(GridType* grid,GraphType* graph);
void       swapUpdateGrid(SwapCtrl* ctrl, GraphType* graph, GridType* grid, int edge);

GridType*  LIBN_Init(void);
GridType*  LIBN_Read(FILE* fp, int NBytes);
void       LIBN_Free(GridType *grid);
void       LIBN_Progen(GraphType *graph, GridType *grid);

int        getBandwidth(int** con, int** netcost, int from, int to);
int        getLatency(int** con, int** latency, int from, int to);
void       Init_Connect(GraphType *graph, GridType *grid);

/* initial.h */
void InitialPartExec(GraphType* graph,GridType* grid);

/* execrefine.c */
int execRefine(GraphType *g, GridType *n, int level, int *guide, PartInfoType *info);//, double* r_time);

/* execrefine_core.h */
void HeapifyFrom(RefCtrl* ctrl,int from);
void HeapifyTo(RefCtrl* ctrl,int to);
void HeapifyAll(RefCtrl* ctrl);

void UpdateHeap(RefCtrl* ctrl,vRef* rvtx,int addundo);
void UpdateHeapEntry(RefCtrl*,int vidx,int to);
void UpdateHeapEntry_Con(RefCtrl* ctrl, int vidx, int movedto1, int movedto2);
void UpdateHeapEntry_Vertex(RefCtrl* ctrk, int vidx);
void RemoveHeapEntry(RefCtrl* ctrl,int vidx,int pro);
vRef* AddHeapEntry(RefCtrl* ctrl,int vidx,int pro,int destreturn);
void UpdateConnect(RefCtrl* ctrl, vRef* rinfo);

void UpdatePHeap(RefCtrl*,vRef* rvtx);

void UndoRecentMoves(RefCtrl*);

/************************** debug */
void debugExec(RefCtrl*);
void debugHeap(RefCtrl*);
int debugExecNoPrint(RefCtrl* ctrl);
int debugHeapNoPrint(RefCtrl* ctrl);
/************************** debug */

/* execrefine_filters.h */
FILTER_FN Filter;
FILTER_FN FilterKl;
FILTER_FN FilterDiffuse;

/* execrefine_ref.h */
int VREF_Build(RefCtrl* ctrl);
void VREF_Free(RefCtrl* ctrl);
vRef* VREF_AddBnd(RefCtrl* ctrl,int v,int from,int to);

void CONT_Ini(RefCtrl* ctrl,vRefCont* cont);
vRef* CONT_Add(RefCtrl* ctrl,vRefCont* cont,
	       int idx,int from,int to,double deltaF,double deltaT,double deltaO,int dOflag);
vRef* CONT_Rem(RefCtrl* ctrl,vRefCont* cont,vRef* rinfo);
void CONT_Free(RefCtrl* ctrl,vRefCont* cont);

/* util.h */
void readfiles( GraphType** graph,char* F_graph,
		GridType** grid,char* F_grid, int NBytes );
double gettimes();

/* projback.h */
void ProjBack(GraphType *graph, GridType *grid, PartInfoType *info);

/* mlp.h */
void MultiLevelPartition(GraphType *graph, GridType *grid, PartInfoType *info);
void ExecTime_FullWeight(GraphType* graph, GridType* grid);

/* execrefine_gain.h */
GAIN_FN   GainFlow;

/* execrefine_undo.h */
UNDO_FN   NoUndo;
UNDO_FN   UndoKl;

#endif
